package ru.compft.common.data.acl;

import ru.compft.common.data.meta.acl.AclSidTableMeta;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: VVasiliev
 * Date: 01.11.12
 * Time: 11:59
 * <p/>
 * Класс представляющий объект "Идентификаторы в ACL"
 * <p/>
 * CREATE TABLE IF NOT EXISTS ACL_SID (
 * ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 * PRINCIPAL VARCHAR(1) NOT NULL,
 * SID VARCHAR(100) NOT NULL,
 * CONSTRAINT UNIQUE_UK_1 UNIQUE(SID,PRINCIPAL)
 * )
 */
@Entity
@Table(name = AclSidTableMeta.TABLE_NAME, uniqueConstraints = {
        @UniqueConstraint(columnNames = {AclSidTableMeta.PRINCIPAL, AclSidTableMeta.SID})})
public class AclSid implements Serializable {
    private static final long serialVersionUID = -8394178112600469943L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = AclSidTableMeta.ID, unique = true, nullable = false)
    private Long id;

    @Column(name = AclSidTableMeta.PRINCIPAL, nullable = false, length = 1)
    private String principal;

    @Column(name = AclSidTableMeta.SID, nullable = false, length = 100)
    private String sid;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPrincipal() {
        return principal;
    }

    public void setPrincipal(String principal) {
        this.principal = principal;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }
}
